package com.group02.community.controller;

import com.group02.community.entity.owner.ZyOwnerRoomRecord;
import com.group02.community.service.OwnerRoomRecordService;
import com.group02.community.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
public class OwnerRoomRecordController {

    @Autowired
    private OwnerRoomRecordService ownerRoomRecordService;

    /**
     * 通过roomId获取对印的record
     * @param roomId
     * @return
     */
    @GetMapping("/ownerRoomRecord/{roomId}")
    public ResponseResult<List<ZyOwnerRoomRecord>> getRecordByRoomId(@PathVariable String roomId){
        return ResponseResult.ok(ownerRoomRecordService.getRecordByRoomId(roomId));
    }

    @GetMapping("/ownerRoomRecord/audit")
    public ResponseResult<String> auditOwner(ZyOwnerRoomRecord zyOwnerRoomRecord){
        ownerRoomRecordService.addRecord(zyOwnerRoomRecord);
        return ResponseResult.ok("修改成功");
    }
}
